<!DOCTYPE html>
<html>
<head>
	<title>后台</title>
	<link rel="stylesheet" type="text/css" href="/bower_components\bootstrap\dist\css\bootstrap.min.css">
	<link rel="stylesheet" type="text/css" href="/style/article.css">
	<script type="text/javascript" src = '//cdn.bootcss.com/jquery/1.12.4/jquery.min.js'></script>
	<script type="text/javascript" src = '/bower_components\upload-jquery\jquery.upload.js'></script>
	<script type="text/javascript" src='/bower_components\bootstrap\dist\js\bootstrap.min.js'></script>
	<script type="text/javascript" src='/bower_components\kindeditor\kindeditor-min.js'></script>
	<script type="text/javascript" src='/bower_components\kindeditor\lang\zh-CN.js'></script>
</head>
<body>
	<div class="container">
		<div class="row">
			<div class="col-md-offset-2 col-md-8">
				<div class="page-header">
					添加文章<a href="/addmin/addArticle" class="btn btn-xs btn-info pull-right">添加文章</a>
				</div>
				<form action="/addmin/degArticle" method="POST">
					<input type="hidden" name="id" value="<%= articles.id%>">
					<div class="form-group">
						<label for="exampleInputEmail1">文章标题</label>
						<input type="text" class="form-control" name="title" value="<%= articles.title%>">
					</div>
					<div class="form-group">
						<label for="exampleInputPassword1">图片</label><br/>
							<img id="image_preview" name="img" src="<%= articles.img%>" class="img-thumbnail" title="图片预览">
						<div class="row">
							<div class="col-md-8">
								<input id="image" class="form-control" name="img" value="<%= articles.img%>" >
							</div>
							<div class="col-md-4">
								<input type="button" class="btn btn-success" onclick="doUpload()" value="点击上传">
							</div>
						</div>
					</div>
					<div class="form-group">
						<label for="exampleInputPassword1">文章内容</label>
						<textarea class="form-control" name="content"><%= articles.content%></textarea>
					</div>
					<div class="form-group">
						<select class="form-control"  name="cata_id">
						<% for(var i = 0; i<catalogs.length; i++){%>
							<option <% if(articles.cata_id==catalogs[i].id){%> selected="selected"<% }%> value="<%= catalogs[i].id%>" class="form-control">
							<%= catalogs[i].name%></option>
						<%}%>
						</select>
					</div>
					<div class="form-group">
						<button type="submit" class="btn btn-success">提交</button>
						<a href="/addmin" class="btn btn-info pull-right">返回</a>
					</div>
				</form>

				<!-- <form method="post" action="/addmin/uploadFile" enctype="multipart/form-data" name="fileForm" target="fileUpload">
					<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
						<div class="modal-dialog" role="document">
							<div class="modal-content">
								<div class="modal-header">
									<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
									<h4 class="modal-title" id="myModalLabel">上传文件</h4>
								</div>
									<div class="modal-body">
										<input type="file" class="fileInput" name="fileInput">
									</div>
								<div class="modal-footer">
									<input class="btn btn-info" type="submit" value="上传"  />
								</div>
							</div>
						</div>
					</div>
				</form> -->
				<iframe name="fileUpload" class="hidden"></iframe>
			</div>
		</div>
	</div>
</body>
</html>
<script type="">
		var editor;
	KindEditor.ready(function(K) {
		editor = K.create('textarea[name="content"]', {
			allowFileManager : true
		})
	});
	/*function aaaa(a){
		$("#image").val(a)
		$('#myModal').modal('hide')
	}*/
	function doUpload(){
		$.upload({
			// 上传地址
			url: '/addmin/uploadFile', 
			// 文件域名字
			fileName: 'fileInput', 
			// 其他表单数据
			params: {},
			// 上传完成后, 返回json, text
			dataType: 'text',
			// 上传之前回调,return true表示可继续上传
			onSend: function() {
					return true;
			},
			// 上传之后回调
			onComplate: function(data) {
					$("#image").val(data);
					$("#image_preview").attr("src",data)
			}
		});
	}
</script>